import request from '@/utils/request'
import { type Result } from '@/types/result'
import type { UploadFile } from 'element-plus' // 引入文件类型

// 上传文件到 MinIO
export function uploadFilesApi(files: UploadFile[]): Promise<Result> {
  const formData = new FormData()
  files.forEach(file => {
    formData.append('files', file.raw!) // 将每个文件添加到 FormData 中
  })
  return request.post('/upload', formData)
}

// 删除 MinIO 中的文件
export function deleteFileApi(fileName: string): Promise<Result> {
  return request.delete(`/upload/delete?filename=${fileName}`)
}
